﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TiposComuns.Objectos;
using System.Security.Permissions;

namespace TiposComuns.Excepcoes
{
    [Serializable]
    public class FriendNotAvailableException : ApplicationException
    {
        private Person friend;

        public FriendNotAvailableException(Person friend)
        {
            this.friend = friend;
        }


        public FriendNotAvailableException(System.Runtime.Serialization.SerializationInfo info,
        System.Runtime.Serialization.StreamingContext context)
            : base(info, context)
        {
            friend = (Person)info.GetValue("friend",typeof(Person));

        }

        [SecurityPermissionAttribute(SecurityAction.Demand,SerializationFormatter = true)]
        public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            base.GetObjectData(info, context);
            info.AddValue("friend", friend);
        }

        public Person Friend
        {
            get { return friend; }
        }
    }
}
